package com.lovo.project2.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lovo.project2.bean.CartBean;
import com.lovo.project2.mapper.ICartBeanMapper;
import com.lovo.project2.service.ICartBeanService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CartBeanServiceImpl extends ServiceImpl<ICartBeanMapper, CartBean> implements ICartBeanService {
    @Override
    public List<CartBean> queryAllByUserId(int userId) {

        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",userId);

        return  baseMapper.selectList(queryWrapper);
    }

    @Override
    public void addCartBean(CartBean cartBean) {

        baseMapper.insert(cartBean);

    }

    @Override
    public void updateCartBean(CartBean cartBean) {
baseMapper.updateById(cartBean);
    }

    @Override
    public void removeCart(int cartBeanId) {
baseMapper.deleteById(cartBeanId);
    }

    @Override
    public void removeAllShoppCar(int userId) {

      QueryWrapper  queryWrapper=new QueryWrapper()  ;
      queryWrapper.eq("user_id",userId);
baseMapper.delete(queryWrapper);
    }
}
